package bb.lanxing.model.json;

import java.io.Serializable;

import com.alibaba.fastjson.annotation.JSONField;

import android.os.Parcel;
import android.os.Parcelable;

public class RouteLeg implements Parcelable, Serializable {
    public static final Creator<RouteLeg> CREATOR = new Creator<RouteLeg>() {
        @Override
        public RouteLeg createFromParcel(Parcel parcel) {
            return new RouteLeg(parcel);
        }

        @Override
        public RouteLeg[] newArray(int i) {
            return new RouteLeg[i];
        }
    };
    private RouteStep.IntValuePair distance;
    private RouteStep.IntValuePair duration;
    @JSONField(name = "end_address")
    private String endAddress;
    @JSONField(name = "end_location")
    private RoutePoint endLocation;
    @JSONField(name = "start_address")
    private String startAddress;
    @JSONField(name = "start_location")
    private RoutePoint startLocation;
    private RouteStep[] steps;
    @JSONField(name = "via_waypoint")
    private WayPoint[] viaWayPoint;

    public RouteLeg() {
    }

    protected RouteLeg(Parcel parcel) {
        this.distance = (RouteStep.IntValuePair) parcel.readParcelable(RouteStep.IntValuePair.class.getClassLoader());
        this.duration = (RouteStep.IntValuePair) parcel.readParcelable(RouteStep.IntValuePair.class.getClassLoader());
        this.startAddress = parcel.readString();
        this.endAddress = parcel.readString();
        this.startLocation = (RoutePoint) parcel.readParcelable(RoutePoint.class.getClassLoader());
        this.endLocation = (RoutePoint) parcel.readParcelable(RoutePoint.class.getClassLoader());
        this.viaWayPoint = (WayPoint[]) parcel.createTypedArray(WayPoint.CREATOR);
        this.steps = (RouteStep[]) parcel.createTypedArray(RouteStep.CREATOR);
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public RouteStep.IntValuePair getDistance() {
        return this.distance;
    }

    public void setDistance(RouteStep.IntValuePair intValuePair) {
        this.distance = intValuePair;
    }

    public RouteStep.IntValuePair getDuration() {
        return this.duration;
    }

    public void setDuration(RouteStep.IntValuePair intValuePair) {
        this.duration = intValuePair;
    }

    public String getStartAddress() {
        return this.startAddress;
    }

    public void setStartAddress(String str) {
        this.startAddress = str;
    }

    public String getEndAddress() {
        return this.endAddress;
    }

    public void setEndAddress(String str) {
        this.endAddress = str;
    }

    public RoutePoint getStartLocation() {
        return this.startLocation;
    }

    public void setStartLocation(RoutePoint routePoint) {
        this.startLocation = routePoint;
    }

    public RoutePoint getEndLocation() {
        return this.endLocation;
    }

    public void setEndLocation(RoutePoint routePoint) {
        this.endLocation = routePoint;
    }

    public WayPoint[] getViaWayPoint() {
        return this.viaWayPoint;
    }

    public void setViaWayPoint(WayPoint[] wayPointArr) {
        this.viaWayPoint = wayPointArr;
    }

    public RouteStep[] getSteps() {
        return this.steps;
    }

    public void setSteps(RouteStep[] routeStepArr) {
        this.steps = routeStepArr;
    }

    @Override
    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeParcelable(this.distance, i);
        parcel.writeParcelable(this.duration, i);
        parcel.writeString(this.startAddress);
        parcel.writeString(this.endAddress);
        parcel.writeParcelable(this.startLocation, i);
        parcel.writeParcelable(this.endLocation, i);
        parcel.writeTypedArray(this.viaWayPoint, i);
        parcel.writeTypedArray(this.steps, i);
    }

    public static class WayPoint implements Parcelable, Serializable {
        public static final Creator<WayPoint> CREATOR = new Creator<WayPoint>() {
            @Override
            public WayPoint createFromParcel(Parcel parcel) {
                return new WayPoint(parcel);
            }

            @Override
            public WayPoint[] newArray(int i) {
                return new WayPoint[i];
            }
        };
        @JSONField(name = "step_index")
        int index;
        @JSONField(name = "step_interpolation")
        double interpolation;
        RoutePoint location;

        public WayPoint() {
        }

        protected WayPoint(Parcel parcel) {
            this.location = (RoutePoint) parcel.readParcelable(RoutePoint.class.getClassLoader());
            this.index = parcel.readInt();
            this.interpolation = parcel.readDouble();
        }

        @Override
        public int describeContents() {
            return 0;
        }

        public RoutePoint getLocation() {
            return this.location;
        }

        public void setLocation(RoutePoint routePoint) {
            this.location = routePoint;
        }

        public int getIndex() {
            return this.index;
        }

        public void setIndex(int i) {
            this.index = i;
        }

        public double getInterpolation() {
            return this.interpolation;
        }

        public void setInterpolation(double d) {
            this.interpolation = d;
        }

        @Override
        public void writeToParcel(Parcel parcel, int i) {
            parcel.writeParcelable(this.location, i);
            parcel.writeInt(this.index);
            parcel.writeDouble(this.interpolation);
        }
    }
}
